<template>
	<view>
		<agreement ref="agreement"></agreement>
		<swiper v-if="isReady" :indicator-dots="startImgArray.length < 2 ? false:true" style="height: 1200rpx;" 
			indicator-color="#555555" indicator-active-color="#BEBEBE">
			<swiper-item v-for="(item,index) in startImgArray" class="note-center">
				<image :src="previewUrl + item" style="width: 750rpx;height: 800rpx;"></image>
				<view class="main-title">企服云</view>
				<!-- <view class="sub-title">站在新的高度</view> -->
				<view class="sub-title">一次选择，终生享受</view>
				<button v-if="index == startImgArray.length - 1" class="start-button" @click="getStart">租户登录</button>
				<button v-if="index == startImgArray.length - 1" class="start-button" @click="getStartFree">游客登录</button>
			</swiper-item>
<!-- 			<swiper-item class="note-center">
				<image :src="previewUrl + startImgArray[1]" style="width: 750rpx;height: 800rpx;"></image>
				<view class="main-title">博邦管家</view>
				<view class="sub-title">重温华夏文明</view>
			</swiper-item>
			<swiper-item class="note-center">
				<image :src="previewUrl + startImgArray[2]" style="width: 750rpx;height: 800rpx;"></image>
				<view class="main-title">博邦管家</view>
				<view class="sub-title">一次选择</view>
			</swiper-item>
			<swiper-item class="note-center">
				<image :src="previewUrl + startImgArray[3]" style="width: 750rpx;height: 800rpx;"></image>
				<view class="main-title">博邦管家</view>
				<view class="sub-title">终生享受</view>
				<button class="start-button" @click="getStart">租户登录</button>
				<button class="start-button" @click="getStartFree">游客登录</button>
			</swiper-item> -->
		</swiper>
	</view>
</template>

<script>
	import {
		ONLINE_SERVER_ADDRESS_BASE,
		syncGetOrder,
		syncPriceInfo,
		myUploadFile,
	} from "../../util/network.js"
	export default{
		data() {
			return {
				userInfo:[],
				startImgArray:[],
				isReady:false,
				previewUrl:`${ONLINE_SERVER_ADDRESS_BASE}/file/preview/`,
				update:true,
				strArray:[''],
			}
		},
		
		onLoad: async function() {
			
			this.userInfo = uni.getStorageSync('userinfo')
			console.log("ceshi",this.userInfo)
			if(this.userInfo != ""){
				uni.switchTab({
					url:"/pages/home/home"
				})
			}else{
				this.getStartBanner()
			}
			// if(uni.getStorageSync('first')){

			// }else{
			//   this.$nextTick(()=>{
			//     this.$refs.agreement.show(true)
			//   })
			// }
			
		},
		
		methods:{
			getStart(){
				uni.redirectTo({
					url:'../login/login'
				})
			},
			getStartFree(){
				uni.switchTab({
					url:"/pages/home/home"
				})
			},
			getStartBanner(){
				let _this = this
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE}/banner/list`,
					data:{ 
							type:0,
					},
					method:'GET',
					success: function (res) {
						console.log('启动页banner',res)
						if(res.data.code == 200){
							try{
								_this.startImgArray = res.data.data.bannerList[0].pictureId.split(',')
							}catch(e){
								_this.startImgArray = [0]
								//TODO handle the exception
							}
							
							_this.isReady = true
						}
					}
				})
			},
		}
	}
</script>
<style>

	.note-center{
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.main-title{
		margin: 40rpx 0 20rpx 0;
		font-size: 45rpx;
		font-weight: 1000;
		color: #555555;
	}
	.sub-title{
		font-size: 30rpx;
		font-weight: 400;
		color: #555555;
	}
	.start-button{
		background-color: #007AFF;
		color: #FFFFFF;
		width: 400rpx;
		margin: 20rpx 0 0 0;
	}
</style>
